<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


<html>
    <head>
        <title>人事档案变更</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8">
        <link href="../../css/mine.css" type="text/css" rel="stylesheet">
        <script src="/js/jquery.js"></script>
    </head>

    <body>

        <div class="div_head">
            <span>
                <span style="float:left">当前位置是：-》人事管理 -》人事档案管理</span>
                <span style="float:right;margin-right: 8px;font-weight: bold">
                    <a style="text-decoration: none" href="list.jsp">【返回】</a>
                </span>
            </span>
        </div>
        <div></div>

        <div style="font-size: 13px;margin: 10px 5px">
            <form id="form" action="/personnel/modify" method="post">
            <input type="hidden" name="id" value="${personnel.id}"/>
            <input type="hidden" id="checkStatus" value="${personnel.checkstatus}"/>
            <table border="1" width="100%" class="table_a">
                <tr>
                    <td width="120px;">档案编码<span style="color:red">*</span>：</td>
                    <td><input readonly type="text" name="danganid" value="${personnel.danganid}" /></td>
                </tr>

                <tr>
                    <td>所属部门<span style="color:red">*</span>：</td>
                    <td>

                        <select id="dept" name="appartment">
                            <option value="-1">---请选择---</option>
                            <c:forEach items="${deptList}" var="dept">
                                <option value="${dept.id}" ${dept.id eq personnel.appartment?"selected":""}>
                                        ${dept.appartmentfullname}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
               
                <tr>
                    <td>档案状态<span style="color:red">*</span>：</td>
                    <td>
						<select name="status">
							<option value="-1">--请选择--</option>
							<option ${personnel.status eq "试用期"?"selected":""}>试用期</option>
                            <option ${personnel.status eq "实习员工"?"selected":""}>实习员工</option>
							<option ${personnel.status eq "正式员工"?"selected":""}>正式员工</option>
							<option ${personnel.status eq "离职"?"selected":""}>离职</option>
							<option ${personnel.status eq "已删除"?"selected":""}>已删除</option>

						</select>
					</td>
                </tr>

                <tr>
                    <td>所属职位<span style="color:red">*</span>：</td>
                    <td>

                        <select id="role" name="permname">
                            <c:forEach items="${roleList}" var="role">
                                <option value="${role.permname}"
                                    ${role.permname eq personnel.permname ?"selected":""}
                                >
                                    ${role.permname}
                                </option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td>职称编码<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="permid"  value="${personnel.permid}" />
                    </td>
                </tr>


				<tr>
                    <td>姓名<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="username"  value="${personnel.username}"/>
                    </td>                
                </tr>

				<tr>
                    <td>性别：</td>
                    <td>
                        <input type="radio" name="sex" value="男" ${personnel.sex eq '男'?"checked":""} />男

                        <input name="sex" type="radio" value="女" ${personnel.sex eq '女'?"checked":""}/>女
                    </td>                
                </tr>

				<tr>
                    <td>EMAIL：</td>
                    <td>
                        <input type="text" name="email" value="${personnel.email}"/>
                    </td>                
                </tr>

				<tr>
                    <td>联系电话：</td>
                    <td>
                        <input type="text" name="number" value="${personnel.number}" />
                    </td>                
                </tr>

				<tr>
                    <td>住址：</td>
                    <td>
                        <input type="text" name="address" value="${personnel.address}" />
                    </td>                
                </tr>
				<tr>
                    <td>身份证号：</td>
                    <td>
                        <input type="text" name="idcard" value="${personnel.idcard}" />
                    </td>                
                </tr>
				<tr>
                    <td>户口所在地：</td>
                    <td>
                        <input type="text" name="localhost" value="${personnel.localhost}" />
                    </td>                
                </tr>
				<tr>
                    <td>政治面貌：</td>
                    <td>
                        <input type="text" name="zhengzhi" value="${personnel.zhengzhi}"/>
                    </td>                
                </tr>	

				<tr>
                    <td>毕业院校：</td>
                    <td>
						 <input type="text"  name="school" value="${personnel.school}" />
                    </td>
                </tr>


				<tr>
                    <td>专业：</td>
                    <td>
                        <input type="text" name="manager" value="${personnel.manager}"/>
                    </td>                
                </tr>
				<tr>
                    <td>学历：</td>
                    <td>
                        <select name="diploma">
							<option >--请选择--</option>
							<option ${personnel.diploma eq "专科"?"selected":""}>专科</option>
							<option ${personnel.diploma eq "本科"?"selected":""}>本科</option>
							<option ${personnel.diploma eq "硕士"?"selected":""}>硕士</option>
							<option ${personnel.diploma eq "博士"?"selected":""}>博士</option>
						</select>
                    </td>                
                </tr>
				<tr>
                    <td>薪酬标准：</td>
                    <td>
                        <select name="salary">
							<option value="-1">--请选择--</option>
							<option value="1" ${personnel.salary eq "1"?"selected":""}>初级</option>
							<option value="2" ${personnel.salary eq "2"?"selected":""}>中级</option>
							<option value="3" ${personnel.salary eq "3"?"selected":""}>高级</option>
						</select>
                    </td>                
                </tr>
				<tr>
                    <td>开户行：</td>
                    <td>
                        <input type="text" name="accountbank" value="${personnel.accountbank}"/>
                    </td>                
                </tr>
				<tr>
                    <td>银行卡号：</td>
                    <td>
                        <input type="text" name="bankcardnumber" value="${personnel.bankcardnumber}"/>
                    </td>                
                </tr>
				<tr>
                    <td>社保卡号：</td>
                    <td>
                        <input type="text" name="socialcardnumber" value="${personnel.socialcardnumber}"/>
                    </td>                
                </tr>
				<tr>
                    <td>登记人：</td>
                    <td>
                        <input readonly type="text" name="levelperson" value="${personnel.levelperson}"/>
                    </td>                
                </tr>
				<tr>
                    <td>建档时间：</td>
                    <td>
                        <input type="text" name="creattime" readonly
                               value="<fmt:formatDate value="${personnel.creattime}" pattern="yyyy-MM-dd"/>"/>
                    </td>                
                </tr>
				<tr>
                    <td>个人履历：</td>
                    <td>
                        <textarea name="info">${personnel.info}</textarea>
                    </td>                
                </tr>
				<tr>
                    <td>家庭关系信息：</td>
                    <td>
                        <textarea name="family">${personnel.family}</textarea>
                    </td>                
                </tr>
				<tr>
                    <td>备注：</td>
                    <td>
                        <textarea name="des">${personnel.des}</textarea>
                    </td>                
                </tr>
				<tr>
                    <td>简历附件：</td>
                    <td>
                        <input type="file"  value=""/>
                    </td>                
                </tr>
				<tr>
                    <td></td>
                    <td>
                        <a href="">张华个人简历.doc</a>  <a href="">删除</a>
                    </td>                
                </tr>
				
                <tr>
                    <td colspan="2" align="center">
                        <c:if test="${personnel.checkstatus eq '审核通过' or  personnel.checkstatus eq '变更'}">
                            <input type="submit" value="保存">
                        </c:if>

						<input type="reset" value="清空">

                        <c:if test="${personnel.checkstatus eq '审核通过' or  personnel.checkstatus eq '变更'}">
                            <input type="button" value="变更申请" id="checkBtn">
                        </c:if>

                        <c:if test="${personnel.checkstatus eq '变更审核中'}">
                            <input type="button" value="变更审核中" disabled="disabled">
                        </c:if>

                    </td>
                </tr>
            </table>
            </form>
        </div>

        <script>
            //部门/职位列表二级联动
            //部门下拉框绑定改变事件
            $("#dept").change(function () {
                //获取当前选择的部门id
                var deptId=$("#dept").val();
                if (deptId==-1){
                    //未选中具体部门
                    alert("请选择部门！");
                }
                else {
                    //发送AJAX请求，获取部门id对应的所有职位信息
                    $.ajax({
                        url:"/user/getRoles",
                        data:"deptId="+deptId,
                        type:"post",
                        dataType:"json",
                        success:function (result) {
                            //成功
                            //让下拉框的长度为0
                            $("#role")[0].length=0;
                            //遍历职位信息列表，插入Option中
                            for (var i = 0; i < result.length; i++) {
                                //Option(显示到标签对中的值,value值)
                                $("#role")[0].add(new Option(result[i].permname));
                            }
                        }
                    });
                }
            });

            // 提交变更审核:修改状态为变更审核中
            $("#checkBtn").click(function () {
                // var status=$("#checkStatus").val();
                // if (status!="起草"){
                //     alert("当前状态为："+status);
                //     alert("非起草状态下不能提交审核！")
                //     return;
                // }
                console.log("sad")
                //得到表单数据
                var data=$("#form").serialize();
                //发送AJAX请求，提交表单
                $.post(
                    "/personnel/modify-checking",
                    data,
                    function (result) {
                        if (result.code==0){
                            //修改成功
                            //修改审核状态为审核中
                            alert(result.msg);
                            location.href="/personnel/manage";

                        } else {
                            //修改失败
                            alert(result.msg);
                            location.href="/personnel/manage";
                        }
                    },
                    "json"
                );
            });


        </script>
    </body>
</html>